package com.edu.controller;

import com.edu.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/*
 * @Author:princess
 * @Date 2023/11/15 11 15 19:19
 *
 */
@Controller
@RequestMapping("/rest")
public class RestController {
    @GetMapping("/user/{userId}")
    public String user(@PathVariable("userId") int userId){
        System.out.println("执行了查询用户"+userId);
        return "/index.jsp";
    }

    @PostMapping("/user")
    public String testPost(User user){
        System.out.println("执行了新增用户"+user);
        return "/index.jsp";
    }

    @DeleteMapping("/user/{userId}")
    public String testDelete(@PathVariable("userId") int userId){
        System.out.println("执行了删除用户"+userId);
        return "redirect: /SpringMVC_02/index.jsp";
    }

    @PutMapping("/user")
    public String testPut(User user){
        System.out.println("执行了修改用户"+user);
        return "redirect: /SpringMVC_02/index.jsp";
    }
}
